;
var helper = require("../../javascript/helper");
var db = require("../../javascript/mysql");
var mysql = new db.mysqlClient("accident");
function genProductInfo() {
    plan = {
        planA: {
            "year": ["0-9"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["300000"],
            "train_death": ["300000"],
            "ship_death": ["100000"],
            "bus_death": ["100000"]
        },
        planB: {
            "year": ["10-17"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["300000"],
            "train_death": ["300000"],
            "ship_death": ["100000"],
            "bus_death": ["100000"]
        },
        planC: {
            "year": ["10-17"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["500000"],
            "train_death": ["500000"],
            "ship_death": ["300000"],
            "bus_death": ["300000"]

        },
        planD: {
            "year": ["10-17"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["1000000"],
            "train_death": ["1000000"],
            "ship_death": ["500000"],
            "bus_death": ["500000"]

        },
        planE: {
            "year": ["18-65"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["300000"],
            "train_death": ["300000"],
            "ship_death": ["100000"],
            "bus_death": ["100000"]
        },
        planF: {
            "year": ["18-65"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["500000"],
            "train_death": ["500000"],
            "ship_death": ["300000"],
            "bus_death": ["300000"]
        },
        planG: {
            "year": ["10-65"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["1000000"],
            "train_death": ["1000000"],
            "ship_death": ["500000"],
            "bus_death": ["500000"]
        },
        planH: {
            "year": ["10-65"],
            "days": ["1d", "3d", "8d", "1m", "6m", "1y"],
            "people_count": ["1"],
            "airplane_death": ["200000"],
            "train_death": ["200000"],
            "ship_death": ["1000000"],
            "bus_death": ["1000000"]
        }
    }
    for (k in plan) {
        data = helper.product([
            plan[k]["year"], plan[k]["days"], plan[k]["people_count"], plan[k]["airplane_death"], plan[k]["train_death"], plan[k]["ship_death"], plan[k]["bus_death"]
        ])
        for (i = 0; i < data.length; i++) {
            dt = helper.formatProductInfo(data[i], plan[k]);
            dt.name = "长城百万交通意外保障";
            dt.company = "长城人寿";
            if (dt.airplane_death == "300000") {
                if (dt.days == "1d") {
                    dt.price = "3.15";
                } else if (dt.days == "3d") {
                    dt.price = "3.40";
                } else if (dt.days == "8d") {
                    dt.price = "3.75";
                } else if (dt.days == "1m") {
                    dt.price = "7.20";
                } else if (dt.days == "6m") {
                    dt.price = "14.80";
                } else {
                    dt.price = "22.40";
                }
            } else if (dt.airplane_death == "500000") {
                if (dt.days == "1d") {
                    dt.price = "8.30";
                } else if (dt.days == "3d") {
                    dt.price = "8.70";
                } else if (dt.days == "8d") {
                    dt.price = "9.80";
                } else if (dt.days == "1m") {
                    dt.price = "18.20";
                } else if (dt.days == "6m") {
                    dt.price = "39.00";
                } else {
                    dt.price = "59.60";
                }

            } else if (dt.airplane_death == "1000000") {
                if (dt.days == "1d") {
                    dt.price = "13.60";
                } else if (dt.days == "3d") {
                    dt.price = "14.50";
                } else if (dt.days == "8d") {
                    dt.price = "17.85";
                } else if (dt.days == "1m") {
                    dt.price = "30.80";
                } else if (dt.days == "6m") {
                    dt.price = "67.10";
                } else {
                    dt.price = "102.50";
                }
            } else {
                if (dt.days == "1d") {
                    dt.price = "26.80";
                } else if (dt.days == "3d") {
                    dt.price = "29.20";
                } else if (dt.days == "8d") {
                    dt.price = "33.00";
                } else if (dt.days == "1m") {
                    dt.price = "61.50";
                } else if (dt.days == "6m") {
                    dt.price = "133.30";
                } else {
                    dt.price = "205.00";
                }

            }
            mysql.insertData( dt );
        }
      
    }
    mysql.close();

}

